import { getToken } from '@/utils/auth'
import request from '@/utils/request'

export const expertApi = {
  // 分页查询专家库
  loadExpert: params => {
    return request({
      url: '/database/page',
      method: 'get',
      params
    })
  },
  // 新增或修改专家库
  submitExpert: data => {
    return request({
      url: '/database/submit',
      method: 'post',
      headers: { 'Content-Type': 'application/json' },
      data
    })
  },
  // 删除专家库
  delExpert: id => {
    return request({
      url: `/database/delete/${id}`,
      method: 'delete',
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    })
  },
  // 分页查询专家信息
  loadExpertInfo: params => {
    return request({
      url: '/information/page',
      method: 'get',
      params
    })
  },
  // 查询专家详情
  loadExpertInfoDetail: params => {
    return request({
      url: '/information/detail',
      method: 'get',
      params,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    })
  },
  // 新增或修改专家
  submitExpertInfo: data => {
    return request({
      url: '/information/submit',
      method: 'post',
      headers: { 'Content-Type': 'application/json' },
      data
    })
  },
  // 删除专家
  deExpertInfo: id => {
    return request({
      url: `/information/delete/${id}`,
      method: 'delete',
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    })
  },
  // 导入专家
  importInformation: (databaseId, file) => {
    return request({
      url: '/information/import',
      headers: { 'Content-Type': 'multipart/form-data' },
      method: 'post',
      params: databaseId,
      data: file,
      responseType: 'blob'
    })
  },
  // 导出专家
  exportInformation: params => {
    return request({
      url: '/information/export',
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
      method: 'post',
      params,
      responseType: 'blob'
    })
  },
  // 分页获取专家抽取记录
  loadRecord: params => {
    return request({
      url: '/selectLog/page',
      method: 'get',
      params
    })
  }
}
